local app = require 'app'
local game = app.game.running


local dealer = game.ui.element()

dealer.store_watchers = 
{
    ingame = 
    {
        ['$'] = function()
        end,

        ['发牌'] = function(self, store, state)
            self:send()
        end,

        ['通知地主'] = function(self, store, state)
            self:send_seen_card()
        end
    }
}

function dealer:ctor(ingame)
    self.res = "club.threecard.doudizhu/ui/ingame.b:dealer"
    self.ingame = ingame
end

function dealer:send()
    local seats = self.ingame.seats
    for local_no, card_ids in ipairs(game.store.ingame.state.hand_card_ids) do
        local seat = seats[local_no]
        if seat then
            seat.poker_container:clear()
            seat.poker_container:mopai(card_ids)
        end
    end
end

function dealer:send_seen_card()
    local lord_player = game.store.ingame.state.lord_player
    local seat = self.ingame.seats[lord_player.seat.local_no]
    seat.poker_container:mopai(game.store.ingame.state.seen_card_ids)
end

function dealer:clear_scene()
    
end

return dealer